package com.gitee.somenvm.ninerpgitem.core.kether.action

import com.gitee.somenvm.ninerpgitem.core.kether.NAMESPACE
import taboolib.common.platform.function.warning
import taboolib.module.kether.KetherParser
import taboolib.module.kether.actionNow
import taboolib.module.kether.scriptParser
import taboolib.module.nms.ItemTag

object ActionNBT {
    @KetherParser(["nbt"], namespace = NAMESPACE, shared = true)
    fun actionNBT() = scriptParser {
        val key = it.nextToken()
        actionNow {
            val nbt = variables().get<ItemTag>("@NBT").orElse(null)
                ?: warning("kether context does not have nbt!").run { return@actionNow "unknown ItemNBT" }
            nbt.getDeep(key).toString()
        }
    }
}